package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import easier.app.x.swipedismiss.SwipeDismiss;
import easier.app.x.view.DragMoveTouchListener;

public class MainActivity41 extends AppCompatActivity {

    private SwipeDismiss mSwipeDismiss;
    private View mMove;

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity41.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main41 );

        mSwipeDismiss = new SwipeDismiss( this );
        mSwipeDismiss.setCouldSwipeX( 100 );
        initView();
    }

    @Override
    public boolean dispatchTouchEvent( MotionEvent ev ) {

        mSwipeDismiss.onActivityTouchEvent( ev );
        boolean toMove = mSwipeDismiss.isToMove();
        if ( toMove ) {
            return true;
        } else {
            return super.dispatchTouchEvent( ev );
        }
    }

    private void initView() {

        mMove = (View) findViewById( R.id.move );
        mMove.setOnTouchListener( new DragMoveTouchListener( mMove ) );
    }
}